package com.hyper_yang._03_designpatterns.principles.demo2.next;

/**
 * projectName: com.hyper_yang._03_designpatterns.principles.demo2.next
 *
 * @author: sakiko
 * time: 2025/9/26 2:22
 * description: 里氏替换原则 【继承父类而不去改变父类】
 */
public class Test {
    public static void main(String[] args) {
        Rectangle r = new Rectangle();
        r.setLength(20.0);
        r.setWidth(10.0);
        RectangleDemo.resize(r);
        RectangleDemo.printLengthAndWidth(r);

        System.out.println("========================");
        Square s = new Square();
        s.setSide(20.0);
//        RectangleDemo.resize(s); // fixme: 因为接受的是长方形而此时正方形继承的是四边形
        RectangleDemo.printLengthAndWidth(s);
    }
}
